import Vue from 'vue'

import 'normalize.css/normalize.css' // A modern alternative to CSS resets

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import locale from 'element-ui/lib/locale/lang/en' // lang i18n

import '@/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'

import '@/icons' // icon
import '@/permission' // permission control

/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online! ! !
 */
// import { mockXHR } from '../mock'
// if (process.env.NODE_ENV === 'production') {
//   mockXHR()
// }

// import VCharts from 'v-charts'
// Object.defineProperty(Vue.prototype, '$echarts', { value: VCharts })
// Vue.use(VCharts)

import echarts from 'echarts'

Vue.prototype.$echarts = echarts;
//添加字符云，前提要有echarts
import 'echarts-wordcloud/dist/echarts-wordcloud'
import 'echarts-wordcloud/dist/echarts-wordcloud.min'

import dataV from '@jiaminghi/data-view'

Vue.use(dataV);

// 引用swiper
import VueAwesomeSwiper from 'vue-awesome-swiper'

Vue.use(VueAwesomeSwiper);
import 'swiper/dist/css/swiper.css'

Vue.use(ElementUI);

//Websocket
import VueNativeSock from 'vue-native-websocket'

// const wsUrl = "ws://10.2.24.27:8090/websocket/1"
// const wsUrl = "ws://localhost:8090/websocket/1"
const wsUrl = "ws://121.36.12.186:8090/websocket/1";
const mutations = {
  SOCKET_ONOPEN: 'socket/SOCKET_ONOPEN',
  SOCKET_ONCLOSE: 'socket/SOCKET_ONCLOSE',
  SOCKET_ONERROR: 'socket/SOCKET_ONERROR',
  SOCKET_ONMESSAGE: 'socket/SOCKET_ONMESSAGE',
  SOCKET_RECONNECT: 'socket/SOCKET_RECONNECT',
  SOCKET_RECONNECT_ERROR: 'socket/SOCKET_RECONNECT_ERROR'
};

Vue.use(VueNativeSock, wsUrl, {
  store: store,
  mutations: mutations,
  format: "json",
  connectManually: true,
  reconnection: true, // (Boolean) whether to reconnect automatically (false)
  reconnectionAttempts: 5, // (Number) number of reconnection attempts before giving up (Infinity),
  reconnectionDelay: 3000, // (Number) how long to initially wait before attempting a new (1000)
});

//滚动条样式
import HappyScroll from 'vue-happy-scroll'
// 引入css
import 'vue-happy-scroll/docs/happy-scroll.css'

Vue.use(HappyScroll);

//non-passive event listener
import 'default-passive-events'


Vue.config.productionTip = false;

new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
});


